import React, { useState, useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import countSlice, { asyncCount } from './redux/slice'
const { add } = countSlice.actions //这是slice里面自动生成的actionCreator
export default function Count() {
  const count = useSelector((state) => {
    // console.log(state)
    return state.xxx.count
  })
  const dispatch = useDispatch()
  return (
    <div>
      count
      <hr />
      <p>{count}</p>
      <button
        onClick={() => {
          dispatch(add(9))
        }}
      >
        +
      </button>
      <button
        onClick={() => {
          dispatch(asyncCount())
        }}
      >
        +async
      </button>
    </div>
  )
}
